/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package payment;

import java.util.ArrayList;
/**
 *
 * @author LL
 */
public class MoneyFlyWeightFacgory {
    public ArrayList<Money> pizzaToppingInfo = new ArrayList<Money>();
    public MoneyFlyWeightFacgory(){
        this.createMoneyCollection();
    }
    
    public ArrayList<Money> getMoneyByCountry(String tCountry){
        ArrayList<Money> tArrayList = new ArrayList<Money>();
        for(int i=0; i<this.pizzaToppingInfo.size() ;i++){
            if(this.pizzaToppingInfo.get(i).getCountry().equals(tCountry))
                tArrayList.add(this.pizzaToppingInfo.get(i));
        }
        return tArrayList;
    }
    
    public Money getMoneyByCountryAmount(String tCountry,double amount){
        Money tMoney = new Money();
        for(int i=0; i<this.pizzaToppingInfo.size() ;i++){
            if(this.pizzaToppingInfo.get(i).getCountry().equals(tCountry)
              && this.pizzaToppingInfo.get(i).getValue()== amount)
            {
                tMoney = this.pizzaToppingInfo.get(i);
                break;
            }
        }
        return tMoney;
    }
    
    public void resetMoneyCount(){
        for(int i=0; i<this.pizzaToppingInfo.size() ;i++)
            this.pizzaToppingInfo.get(i).setCount(0);
    }
    
    public void createMoneyCollection(){
        //AU
        Money tMoney = new Money();
        tMoney.setCountry("AU");
        tMoney.setValue(100.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("AU");
        tMoney.setValue(50.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("AU");
        tMoney.setValue(20.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("AU");
        tMoney.setValue(10.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("AU");
        tMoney.setValue(5.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("AU");
        tMoney.setValue(1.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("AU");
        tMoney.setValue(0.5);
        this.pizzaToppingInfo.add(tMoney);
        //CN
        tMoney = new Money();
        tMoney.setCountry("CN");
        tMoney.setValue(100.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("CN");
        tMoney.setValue(50.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("CN");
        tMoney.setValue(20.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("CN");
        tMoney.setValue(10.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("CN");
        tMoney.setValue(5.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("CN");
        tMoney.setValue(1.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("CN");
        tMoney.setValue(0.5);
        this.pizzaToppingInfo.add(tMoney);
        //ML
        tMoney = new Money();
        tMoney.setCountry("ML");
        tMoney.setValue(100.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("ML");
        tMoney.setValue(50.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("ML");
        tMoney.setValue(20.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("ML");
        tMoney.setValue(10.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("ML");
        tMoney.setValue(1.00);
        this.pizzaToppingInfo.add(tMoney);
        tMoney = new Money();
        tMoney.setCountry("ML");
        tMoney.setValue(0.5);
        this.pizzaToppingInfo.add(tMoney);
    }
    
    public static void main(String args[]) {
        MoneyFlyWeightFacgory tMoneyFlyWeightFacgory = new MoneyFlyWeightFacgory();
        ArrayList<Money> tArrayList = tMoneyFlyWeightFacgory.getMoneyByCountry("ML");
        for(int i=0; i<tArrayList.size() ;i++){
            System.out.println(tArrayList.get(i).getValue());
        }
    }
}
